// 首页
import React from 'react';
import {Layout, Button, message} from 'antd';
import './Home.css';
import Slider from '../component/Slider/Slider';
// import VipManage from './Vip/VipManage/VipManage'
import IconFont from '../component/logo';
import StoreSet from '../pages/Set/StoreSet';
import {withRouter} from "react-router";
import {observer,inject} from "mobx-react";
import {getsessionstorage,setsessionstorage,removeSessiontorage} from "../utils/utils"
import { Modal, Space } from 'antd';
import {toJS} from "mobx";
import { ExclamationCircleOutlined } from '@ant-design/icons';
import axios from '../utils/http'

// import LuY from "../component/LuY/LuY";
import { BrowserRouter as Router, Redirect, Route } from 'react-router-dom';
// import CouponManagement from './promotion/coupon/CouponManagement';
import Orderlist from './Order/OrderList/OrderList';
import OrderDetail from './Order/OrderList/OrderDetail/OrderDetail';
import { OperatePage, RefundPage } from './Order/OrderList/OrderDetail/CanOperate/CanOperate';
import OrderTeam from './Order/TeamOrderList/TeamOrderList';
import TeamOrderDetail from './Order/TeamOrderList/TeamOrderDetail/TeamOrderDetail';
import DeliveryList from './Order/DeliveryList/DeliveryList';
import DeliveryDetail from './Order/DeliveryList/DeliveryDetail/DeliveryDetail';
import Batch from './Order/Batch/Batch';
const { confirm } = Modal;



// import Orderlist from './Order/OrderList/OrderList'

const { Header, Sider, Content } = Layout;
@withRouter
@inject('lu')
@observer
class Home extends React.Component {


    tokenYan=()=>{
             const that=this
            let data=toJS(that.props.lu.loginer.data)
            // console.log(data)

            // axios.post('/mm-certification/auth/newToken',
            //     data
            // ).then(data=>{
            //     console.log('tonke')
            //     console.log(data)
            //     setsessionstorage('token',data.data.token)
            // })


    }
    tuiChu=()=>{
        const that=this
        let data=toJS(that.props.lu.loginer.data)
        console.log(data)
        confirm({
            title: '您确定退出登录吗',
            icon: <ExclamationCircleOutlined />,

            onOk() {
                removeSessiontorage('user')
                removeSessiontorage('token')
               axios.post('/mm-certification/auth/logout',
                 data
              ).then(data=>{
                 if(data.data.code==200){
               message.success('退出成功')
                     let a=[]
                     that.props.lu.getLoginer(a)
                 }else{

                 }
               })
                that.props.history.push('/login')
            },
            onCancel() {
                console.log('Cancel');
            },
        });




    }
    sheZhi=()=>{
        this.props.history.push('/Home/SheZhi/StoreSet/StoreInfo')
    }

  render() {

     // if(getsessionstorage('user')){
     //     setInterval(this.tokenYan
     //     ,3000)
     // }else{
     //
     // }

    return (

      <Layout>
        <Header>

          <IconFont type="icon-pinduoduo" style={{ fontSize: '40px' }} />
          <span className='gou'>
              <Button onClick={this.sheZhi}>设置</Button>
              <Button onClick={this.tuiChu}>退出</Button>
          </span>

        </Header>
        <Layout classname='hh'>
          <Sider>
            <Slider></Slider>
          </Sider>
          <Content style={{height:'100%'}}>{this.props.children}</Content>
        </Layout>
      </Layout>
    );
  }
}
export default Home;
